package org.mtmi.ui.scenes.actions;

import org.eclipse.swt.widgets.Shell;
import org.mtmi.ui.IMG;
import org.mtmi.ui.actions.Action;
import org.mtmi.ui.drawables.IDrawable;
import org.mtmi.ui.scenes.SceneManager;

public class QuitAction extends Action
{
	public QuitAction() {
		super( PUSH );
	}
	
	@Override
	public String getText() {
		return "Quit";
	}
	
	@Override
	public IDrawable getImage() {
		return IMG.GetD( IMG.I_EXIT );
	}
	
	@Override
	public boolean isEnabled() {
		return true;
	}
	
	@Override
	public void run() {
		final Shell s = SceneManager.getDefault().getScene().getShell();
		//async because some drawing will be done (button/tapUp etc...)
		s.getDisplay().asyncExec( new Runnable() {
			public void run() {
				s.dispose();
			}
		});
	}
}
